import { AnimatorStateLogic } from 'db://app-game/libs/animator/core/AnimatorStateLogic';
import { Role } from '../../../Role';
import { AnimationEventHandler } from '../AnimationEventHandler';

/** 上半身攻击动画逻辑 */
export class RoleUpperStateSkills extends AnimatorStateLogic {
  /** 角色 */
  private role: Role;
  private anim: AnimationEventHandler;
  constructor(role: Role, anim: AnimationEventHandler) {
    super();
    this.role = role;
    this.anim = anim;
  }

  public onEntry(state: AnimatorState, param: AnimatorParams): void {
    const SkillType = param.getNumber('SkillType');
    if (!this.skillMap.has(SkillType)) return;
    this.skillMap.get(SkillType).onEntry(state, param);
  }
  public onUpdate(state: AnimatorState, param: AnimatorParams): void {
    const SkillType = param.getNumber('SkillType');
    if (!this.skillMap.has(SkillType)) return;
    this.skillMap.get(SkillType).onUpdate(state, param);
  }
  public onExit(state: AnimatorState, param: AnimatorParams): void {
    // 1.播放动画结束显示下半身节点
    this.role.RoleView.lowerBody.node.active = true;

    // 2.执行技能动画逻辑退出方法
    const SkillType = param.getNumber('SkillType');
    if (!this.skillMap.has(SkillType)) return;
    this.skillMap.get(SkillType).onExit(state, param);
  }
}
